package hypeerweb;

import java.io.Serializable;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;

public class DownPointingNodeState extends NodeState implements Serializable {
	private static final long serialVersionUID = -7288728346282215850L;

	/**
	 * The StandardNodeState's singleton
	 */
	public static DownPointingNodeState singleton;

	/**
	 * The integer value that represents which state the Node is in
	 */
	public static final int STATE_ID = 1;

	/**
	 * Default constructor
	 */
	private DownPointingNodeState() {}

	/**
	 * Initializes this nodes state and returns it
	 */
	public static DownPointingNodeState getSingleton() {
		if (singleton == null) {
			singleton = new DownPointingNodeState();
		}
		return (DownPointingNodeState) singleton;
	}

	/**
	 * gets the nodes largest neighbor and then returns calls findCapNodeFrom on it and returns that value
	 * 
	 * @param Node
	 *            temp
	 * @param Node
	 *            refNode
	 */
	public Node findCapNodeFrom(Node refNode) {
		assert !refNode.getDownPointers().isEmpty();
		return refNode.getDownPointers().last().getState().findCapNodeFrom(refNode.getDownPointers().last());
	}

	/**
	 * Finds the cap node from the node passed in then finds the insertion point using that returned value and returns it
	 * 
	 * @param Node
	 *            refNode
	 * @param Node
	 *            temp
	 * @throws IllegalAccessException
	 */
	public Node findInsertionPointFrom(Node refNode) {
		throw new NotImplementedException();
	}

	/**
	 * Method getStateID returns the enumerated id of this state
	 * 
	 * @pre <i>None</i>
	 * @post result = STATE_ID
	 */
	public int getStateId() {
		return STATE_ID;
	}

	/**
	 * toString method
	 */
	public String toString() {
		return "Down Pointing Node State";
	}
}